import mongoose from "../mongo.js";

// 公司单位
const unit_schema = new mongoose.Schema(
  {
    base_name: String,
    base_deptname: String,
    sericnum: String,
    name: String,
    nameen: String,
    pid: String,
    fuzename: String,
    city: String,
    address: String,
    tel: String,
    fax: String,
    sort: Number,
    id: String,
  },
  { timestamps: true }
);

const tree_schema = new mongoose.Schema({
  name: String,
});

const structure = new mongoose.Schema({
  id: Number,
  name: String,
  code: Number,
  fuzename: String,
  pid: Number,
  p_id: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "structure",
    default: null,
  },
  sortnum: Number,
});

const unit_model = mongoose.model("unit", unit_schema);
const tree_model = mongoose.model("tree", tree_schema);
const structure_model = mongoose.model("structure", structure);

export { unit_model, tree_model, structure_model };
